package net.moao.netutils;

import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import net.moao.netutils.databinding.ActivityAboutBinding;

/**
 * AboutActivity
 *
 * @author Moao.Net
 * @DATE 2025/6/16
 */
public class AboutActivity extends AppCompatActivity {
    Activity mActivity;
    ActivityAboutBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityAboutBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        mActivity = this;

        try {
            PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
            String versionName = packageInfo.versionName;
            binding.appVersion.setText("当前版本：v" + versionName);
            System.out.println("当前版本号: " + versionName);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }

        binding.btnCloseWindow.setOnClickListener(onClockListener);
    }

    private final View.OnClickListener onClockListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (view.getId() == binding.btnCloseWindow.getId()){
                finish();
            }
        }
    };

}
